package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxx.server.mapper.IdakaMapper;
import com.xxxx.server.pojo.Admin;
import com.xxxx.server.pojo.Idaka;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.service.IIdakaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 辅导员打卡表 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-02
 */
@Service
public class IdakaServiceImpl extends ServiceImpl<IdakaMapper, Idaka> implements IIdakaService {

    @Autowired
    private IdakaMapper idakaMapper;

    @Override
    public List<Idaka> getIdakaByIDid() {
        return idakaMapper.getIdakaByIDid(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }

    @Override
    public RespPageBean getIdakaByPage(Integer currentPage, Integer size, Idaka idaka, String[] beginDateScope) {
        //开启分页
        Page<Idaka> page = new Page<>(currentPage,size);
        IPage<Idaka> IdakaByPage = idakaMapper.getIdakaByPage(page, idaka, beginDateScope);

        RespPageBean respPageBean = new RespPageBean(IdakaByPage.getTotal(), IdakaByPage.getRecords());
        return respPageBean;

    }

    @Override
    public List<Idaka> getIdaka(Integer id) {
        return idakaMapper.getIdaka(id);
    }

}
